/*
date:20210308 pm21:50
key:1.数组划分分成一步
2.冒泡几趟取决于想要第几大的数，一趟保证一个数。
*/
#include<math.h>
#include <stdio.h>
#include<iostream>
#include<sstream>
#include<stdlib.h>
using namespace std;
const int P = 10007;
void change(int& a, int& b)
{
	int k = b;
	b = a;
	a = k;
}

//split数组的函数
int* split(int* A, int L, int R)
{
	int* B = new int[R - L + 1];
	int j = 0;
	for (int i = L - 1; i < R; i++)
	{
		B[j] = A[i];

		j++;
	}
	return B;
}
//冒泡排序,n决定几趟冒泡，最后n个最大是有序的。
int maopao(int* A, int length, int n)
{
	for (int j = 0; j < n; j++)
	{
		for (int i = 0; i < length - 1 - j; i++)
		{
			if (A[i] > A[i + 1])
			{
				change(A[i], A[i + 1]);
			}
		}
	}
	return A[length - n];
}
int main()
{
	int i;

	int n;
	cin >> n;
	int* A = new int[n];
	for (i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	//分割数组
	int l, r;

	//
	int g, k;
	cin >> k;
	for (i = 0; i < k; i++)
	{
		cin >> l >> r;
		int* B = split(A, l, r);
		cin >> g;
		cout << maopao(B, r - l + 1, g) << endl;
	}

}
